<include file="../header" />
<body class="J_scroll_fixed">
<script type="text/javascript">
    function processPage(id, page) {
        var url = "/admin/workorder/process?id=" + id + "&page=" + page + "&home=1";
        window.location.href = url;
    }
</script>
<!--form class="well form-search" method="post" style="float:left" action="{:U('Workorder/index')}">
    <div class="search_type cc mb10">
        <div class="mb10">
        <span class="mr20">
            状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态：{:getEnumSelectWidget($statusEnum, "wo#status", $status, 1)}
            &nbsp;工单号：<input type="text" name="wo#workorder_no-like" value="{$workorder_no}" />
            患者姓名：<input type="text" name="pt#patient_name-like" value="{$patient_name}" />
            <br>
            类&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;型：{:getEnumSelectWidget($typeEnum, "wo#workorder_type", $type, 1)}下单开始时间：<input type="text" value="{$begin_time}" class="date J_date" name="wo#create_time-egt" />
            下单截止时间：<input type="text" value="{$end_time}" class="date J_date" name="wo#create_time-elt" />
            <button class="btn btn-primary" type="submit">搜索</button>
            <a class="btn" href="{:U('Workorder/index')}">重置</a>
        </span>
        </div>
    </div>
</form-->
<div class="wrap J_check_wrap">
    <php>$imgVersion = "2020040601";</php>
    <table class="table table-hover table-bordered">
        <thead>
        <tr>
            <th>工单信息</th>
            <th style="min-width: 1250px" width="1250px">工艺流程</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <foreach name="workorderList" item="vo">
            <tr>
                <php>
                    if($vo["workorder_type"] == 1){
                        $type = "AFO";
                    }
                    if($vo["workorder_type"] == 2){
                        $type = "脊柱";
                    }
                    if($vo["workorder_type"] == 3){
                    $type = "物理检查表";
                    }
                </php>
                <td>工单号：{$vo.workorder_no} {$vo.side}
                    <br>
                    患者：{$vo.patient_name}，{$vo.sex}，{$vo.age}岁，{$vo.diagnosis}
                    <br>
                    检测人：{$vo.examinator}，业务员：{$vo.sales}，处方人：{$vo.prescriber}
                    <br>
                    <if condition="$vo['status'] gt '2' && $vo['workorder_type'] neq '3'">
                        矫形器类型：{$vo.type_name}
                        <br>
                        价格：{$vo.price}，预付款：{$vo.deposit}，预计交付：{$vo.delivery_date}
                    </if>
                </td>

                <php>
                    $processStatusArr=explode(",",$vo["process_status"]);
                    if($vo["workorder_type"] == 1)
                        $processArr = array("取阴模", "检查取阴模","修阳模","检查修阳模","热塑成型","检查热塑成型","打磨抛光","检查打磨抛光","组装对线","半成品适配","穿戴及使用训练","入库");
                    if($vo["workorder_type"] == 2)
                        $processArr = array("取阴模2", "检查取阴模2","修阳模2","检查修阳模2","热塑成型","检查热塑成型","打磨抛光","检查打磨抛光","组装对线","半成品适配2","穿戴及使用训练2","入库");
                    for($i = 0; $i < 12; $i++){
                        if($processStatusArr[$i] == "1"){
                            $processArr[$i] .= "亮";
                        }
                    }
                </php>
                <td>
                    <img style="width: 100px;height: 100px" src="/Template/images/{$processArr.0}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",1)' title="取阴模"/>
                    <img style="width: 100px;height: 100px" src="/Template/images/{$processArr.1}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",2)' title="检查取阴模"/>
                    <img style="width: 100px;height: 100px" src="/Template/images/{$processArr.2}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",3)' title="修阳模"/>
                    <img style="width: 100px;height: 100px" src="/Template/images/{$processArr.3}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",4)' title="检查修阳模"/>
                    <img style="width: 100px;height: 100px" src="/Template/images/{$processArr.4}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",5)' title="热塑成型"/>
                    <img style="width: 100px;height: 100px" src="/Template/images/{$processArr.5}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",6)' title="检查热塑成型"/>
                    <img style="width: 100px;height: 100px" src="/Template/images/{$processArr.6}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",7)' title="打磨抛光"/>
                    <img style="width: 100px;height: 100px" src="/Template/images/{$processArr.7}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",8)' title="检查打磨抛光"/>
                    <img style="width: 100px;height: 100px" src="/Template/images/{$processArr.8}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",9)' title="组装对线"/>
                    <img style="width: 100px;height: 100px" src="/Template/images/{$processArr.9}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",10)' title="半成品适配"/>
                    <img style="width: 100px;height: 100px" src="/Template/images/{$processArr.10}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",11)' title="穿戴及使用训练"/>
                    <img style="width: 100px;height: 100px" src="/Template/images/{$processArr.11}.png?v={$imgVersion}" onclick='javascript:processPage("{$vo.workorder_id}",12)' title="入库"/>
                </td>
                <td>
                    <if condition="$vo['status'] egt $statusEnum['WAITING_DISTPATCH']">
                        <!--a class="btn btn-success" href='{:U("workorder/viewworkorder",array("id"=>$vo["workorder_id"]))}'>接单</a>
                    <else/-->
                        <a style="width: 100px;height: 20px;padding: 5px 0px 5px 0px;" class="btn btn-info" href='{:U("workorder/viewworkorder",array("id"=>$vo["workorder_id"]))}'>查看与打印</a>
                        <br/>
                    </if>
                    <php>
                        $prescriber = 0;
                        $employee_idArr = explode(',', $user['employee_id']);
                        foreach ($employee_idArr as $value) {
                            if($value == $vo['prescriber_id'] && $vo['status'] == '1'){
                                $prescriber = 1;
                            }
                        }
                    </php>
                    <if condition="$prescriber eq 1">
                        <a style="width: 100px;height: 20px;padding: 5px 0px 5px 0px;" class="btn btn-danger" href='{:U("workorder/rx",array("id"=>$vo["workorder_id"]))}'>处方</a>
                        <br/>
                    </if>
                    <php>
                        $needProcess = "0";

                        for($i = 0; $i < 11; $i++){
                        if($processStatusArr[$i] != "1"){
                        $needProcess = "1";
                        }
                        }

                    </php>
                    <if condition="$needProcess eq '1'">
                        <!--a style="width: 100px;height: 20px;padding: 5px 0px 5px 0px;" class="btn btn-danger" href='{:U("workorder/process",array("id"=>$vo["workorder_id"]))}'>{$processPage.name}</a-->
                        <a style="width: 100px;height: 20px;padding: 5px 0px 5px 0px;" class="btn btn-success" href='{:U("workorder/process",array("id"=>$vo["workorder_id"],"home"=>"1"))}'>填写工艺流程</a>
                        <br/>
                    </if>
                    <php>
                        $reviewver = 0;
                        if($vo['review_status'] == 0 && $user['name'] == 'admin' && $vo["status"] > 1){
                            $reviewver = 1;
                        }
                    </php>
                    <if condition="$reviewver eq 1">
                        <a style="width: 100px;height: 20px;padding: 5px 0px 5px 0px;" class="btn btn-danger" onclick="if(confirm('确认【完成工序质量检查】?')==false)return false;" href='{:U("workorder/review",array("id"=>$vo["workorder_id"]))}' >工序质量检查</a>
                    </if>
                    <php>
                        $auditor = 0;
                        if($vo['audit_status'] == 0 && $vo["status"] > 1){
                            $employee_idArr = explode(',', $user['employee_id']);
                            foreach ($employee_idArr as $value) {
                                if($value == $vo['prescriber_id']){
                                    $auditor = 1;
                                }
                            }
                        }
                    </php>
                    <if condition="$auditor eq 1">
                        <a style="width: 100px;height: 20px;padding: 5px 0px 5px 0px;" class="btn btn-danger" onclick="if(confirm('确认【完成质量审核】?')==false)return false;" href='{:U("workorder/audit",array("id"=>$vo["workorder_id"]))}' >质量审核</a>
                    </if>
                </td>
            </tr>
        </foreach>
        </tbody>
    </table>
</div>
<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>